#include<stdio.h>
#include<string.h>
#include<sys/socket.h>
#include<netdb.h>
#include<arpa/inet.h>

#define HTTP_PORT 80
#define BAIDU_SERVER "www.baidu.com"
void fun(char *str1, char *str2)
{
	while(*str1++=*str2++);
	printf("str1=%s\n",str1);

}
int main()
{
	char *tp_str="1234567";
	char *tp1="abcdefg";
	fun(tp_str,tp1);
	int str_len=strlen(tp_str);
	printf("len=%d\n",str_len);
	int i=3;
	int j=3;
	printf("i++ is %d and ++j is %d\n",i++,++j);
	char c1,c2;
	c1='A';
	c2=c1+32;
	printf("c2 is %c and char %d\n",c2,c2);
//force type change,(int) (5.6\3.9),(float)(5%3)
	printf("res is %f\n",(float)(c2%i));
	/*int a1,a2,a3;
	scanf("%d,%d",&a1,&a2); //input like 2,3
	a3=(a1>a2)?a1:a2;
	printf("the big one is %d\n",a3);*/
	int a4=1,sum=0;
	do{
		sum=sum+a4;
		a4++;
	}while(a4<=100);
	printf("sum=%d\n",sum);
	Connet(HTTP_PORT,BAIDU_SERVER);
	
return 1;
}

int Connet(int port,char *server)
{
	struct in_addr ip_addr;
	struct hostent *host;
	struct sockaddr_in dst_addr;
	host=gethostbyname(server);
	if(!host)
		return -1;
	memset(&dst_addr,0,sizeof(dst_addr));
	dst_addr.sin_family=AF_INET;
	memcpy(&(dst_addr.sin_addr),host->h_addr,sizeof(struct in_addr));
	printf("server:%s,IP:%s\n",server,inet_ntoa(dst_addr.sin_addr));
	return 1;	
}

